import React, { Component } from "react";

class DemoComponent extends Component {
    state = {
        arr: [1,2,3],
    };
    render() {
        let { arr } = this.state;
        return (
            <>
                {
                  arr.map((item, index) => {
                      return (
                          <span key={index} style={{
                              display: "inline-block",
                              width: 100,
                              height: 100,
                              backgroundColor: "blue",
                              marginRight: 10,
                              color: "#fff",
                          }}>
                              {item}
                          </span>
                      );
                  })
                }
                <br />
                <button onClick={() => {
                    arr.push(4);
                    this.setState(
                      {
                        arr,
                      }
                    );
                }}>add span</button>
            </>
        )
    };
};

export default DemoComponent;
